﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Database.NHibernateInterface;
using Domain.Repositories;
using Domain.Entities;
using Database.Hibernate;
using NHibernate.Criterion;

namespace Database.Repositories
{
    public class QuestionRepository:BaseRepository<Question>, IQuestionRepository
    {
        public QuestionRepository(ISessionProvider sessionProvider)
            : base(sessionProvider)
        {
        }
        public IEnumerable<Question> GetListOfRandomQuestions(Chapter chapter, int count)
        {
            return Session.CreateCriteria<Question>().Add(Restrictions.Like("Chapter", chapter)).AddOrder(new RandomOrder()).SetMaxResults(count).List<Question>();
        }

        public IEnumerable<Question> GetListOfQuestionsForChapter(Chapter chapter)
        {
            return Session.CreateCriteria<Question>().Add(Restrictions.Like("Chapter", chapter)).List<Question>();
        }
    }
}
